/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sadhar.sipp.nilaipatokanharga;

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
import org.sadhar.errhandler.ClassAntiNull;
import org.sadhar.sipp.nilaipatokanharga.NilaiPatokanHargaDAO;
import org.sadhar.sipp.nilaipatokanharga.NilaiPatokanHargaDAOImpl;
import org.sadhar.sia.framework.ClassApplicationModule;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Textbox;

/**
 *
 * @author Yohan Hardinugroho
 */
public class NilaiPatokanHargaPopupWnd extends ClassApplicationModule {

    private Textbox txtboxKeySearch;
    private Listbox lstboxDaftarHarga;
    private NilaiPatokanHargaDAO nilaiPatokanHargaDAO = new NilaiPatokanHargaDAOImpl();

    public void onCreate() throws Exception {
        txtboxKeySearch = (Textbox) getFellow("txtboxKeySearch");
        lstboxDaftarHarga = (Listbox) getFellow("lstboxDaftarHarga");


        List<Map> result = nilaiPatokanHargaDAO.listDetails(txtboxKeySearch.getValue());
        for (Map m : result) {
            Listitem li = new Listitem();
            li.appendChild(new Listcell(ClassAntiNull.AntiNullString(m.get("jenisBarang"))));
             li.appendChild(new Listcell(ClassAntiNull.AntiNullString(m.get("namaBarang"))));
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            li.appendChild(new Listcell(sdf.format(ClassAntiNull.AntiNullDate(m.get("tglBeli")))));
            li.appendChild(new Listcell(ClassAntiNull.AntiNullString(m.get("hargaBeliSatuanPerKecil"))));
            lstboxDaftarHarga.appendChild(li);
        }
    }
}
